package com.wealth.scsj.b_app.presenter;

import com.orhanobut.logger.Logger;
import com.wealth.scsj.b_app.base.CashBalanceBase;
import com.wealth.scsj.b_app.bean.BaseBean;
import com.wealth.scsj.b_app.bean.GetOwnTreasureInfoBean;
import com.wealth.scsj.b_app.bean.SelectUserHasBindBankCardBean;
import com.wealth.scsj.b_app.model.CashBalanceModel;


import dkmvp.mvp.BasePresenter;
import dkmvp.net.ResponseCallback;
import okhttp3.RequestBody;

/**
 * 查询用户已绑定的银行卡presenter
 * 买家版钱包界面查询 查询余额和费率
 * 申请提现
 */

public class CashBalancePresenter extends BasePresenter implements CashBalanceBase.IPresenter {

    private CashBalanceBase.IModel mModel;
    private CashBalanceBase.IView mView;

    public CashBalancePresenter(CashBalanceBase.IView view) {
        mView = view;
        mModel = new CashBalanceModel();
    }

    /**
     * 查询用户已绑定的银行卡
     */
    @Override
    public void deliverQuerybankCardData(RequestBody requestBody) {
        addSubscription(mModel.mQuerybankCardData(requestBody, new ResponseCallback<SelectUserHasBindBankCardBean>() {
            @Override
            public void onSuccess(SelectUserHasBindBankCardBean result) {
                if (result.getStatusCode() == 200) {
                    mView.vQuerybankCardSuccessMsg("获取成功", result);
                } else {
                    mView.showErrorMsg(result.getMsg());
                }
            }

            @Override
            public void onFaild(String msg) {
                mView.showErrorMsg(msg);
                Logger.e("onFaild"+msg);
            }
        }));
    }

    /**
     * 买家版钱包界面查询 查询余额和费率
     * @param requestBody
     */
    @Override
    public void deliverGetOwnTreasureInfoData(RequestBody requestBody) {
        addSubscription(mModel.mGetOwnTreasureInfoData(requestBody, new ResponseCallback<GetOwnTreasureInfoBean>() {
            @Override
            public void onSuccess(GetOwnTreasureInfoBean result) {
                if (result.getStatusCode() == 200) {
                    mView.vGetOwnTreasureInfoSuccessMsg("获取成功", result);
                } else {
                    mView.showErrorMsg(result.getMsg());
                }
            }

            @Override
            public void onFaild(String msg) {
                mView.showErrorMsg(msg);
                Logger.e("onFaild"+msg);
            }
        }));
    }

    /**
     * 申请提现
     * @param requestBody
     */
    @Override
    public void deliverWithdrawCashData(RequestBody requestBody) {
        addSubscription(mModel.mWithdrawCashData(requestBody, new ResponseCallback<BaseBean>() {
            @Override
            public void onSuccess(BaseBean result) {
                if (result.getStatusCode() == 200) {
                    mView.vWithdrawCashSuccessMsg("获取成功", result);
                } else {
                    mView.showErrorMsg(result.getMsg());
                }
            }

            @Override
            public void onFaild(String msg) {
                mView.showErrorMsg(msg);
                Logger.e("onFaild"+msg);
            }
        }));
    }
}
